VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "TestLocalAssertions"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit

Private mLocal As LocalAssertions

Private mResult As Boolean
Private mActual As Variant
Private mExpected As Variant
Private mMessage As String
Private mDescription As String

Public Sub testFailNoMessage()
givenLocalAssertion
whenFail
thenFailTestResultIs
End Sub
Public Sub testFailMessage()
givenLocalAssertion
whenFail "fail"
thenFailTestResultIs "fail"
End Sub
Public Sub testIsTrueTrue()
givenLocalAssertion
whenIsTrue True, "passed"
thenTrueTestResultIs True, True, "passed", "Actual was true"
End Sub
Public Sub testIsTrueFalse()
givenLocalAssertion
whenIsTrue False, "failed"
thenTrueTestResultIs False, True, "failed", "Actual should have been true"
End Sub
Public Sub testIsFalseTrue()
givenLocalAssertion
whenIsFalse True, "failed"
thenTrueTestResultIs False, False, "failed", "Actual should have been false"
End Sub
Public Sub testIsFalseFalse()
givenLocalAssertion
whenIsFalse False, "passed"
thenTrueTestResultIs True, False, "passed", "Actual was false"
End Sub
Public Sub testIntegersAreEqual()
givenLocalAssertion
whenValuesAreEqual 1, 1, "passed"
thenEqualsTestResultIs True, 1, 1, "passed", "1 is the same as 1"
End Sub
Public Sub testIntegersAreNotEqual()
givenLocalAssertion
whenValuesAreNotEqual 1, 2, "failed"
thenEqualsTestResultIs False, 1, 2, "failed", "1 is not the same as 2"
End Sub

''
''
Private Sub givenLocalAssertion()
Set mLocal = New LocalAssertions
setNotification Me
End Sub

Private Sub whenFail(Optional message As String = "")
On Error Resume Next
mLocal.Fail message
End Sub
Private Sub whenIsTrue(value As Boolean, message As String)
On Error Resume Next
mLocal.isTrue value, message
End Sub
Private Sub whenIsFalse(value As Boolean, message As String)
On Error Resume Next
mLocal.isFalse value, message
End Sub
Private Sub whenValuesAreEqual(actual As Variant, expected As Variant, Optional message As String = "")
mLocal.equals actual, expected, message
End Sub
Private Sub whenValuesAreNotEqual(actual As Variant, expected As Variant, Optional message As String = "")
On Error Resume Next
mLocal.equals actual, expected, message
End Sub

Private Sub thenFailTestResultIs(Optional message As String = "")
assert.isFalse mResult, "result is False"
assert.equals TypeName(mActual), "Empty", "No Actual"
assert.equals TypeName(mExpected), "Empty", "No Expected"
assert.equals mMessage, message, "Message is '" + message + "'"
assert.equals mDescription, "Fail", "Fail description"
End Sub
Private Sub thenTrueTestResultIs(result As Boolean, value As Boolean, message As String, desc As String)
assert.equals mResult, result, "result is " + Str(result)
assert.equals mActual, value Xor (Not result), "Actual is" + Str(value Xor (Not result))
assert.equals mExpected, value, "Expected is " + Str(value)
assert.equals mMessage, message, "Message is '" + message + "'"
assert.equals mDescription, desc, "Fail description"
End Sub
Private Sub thenEqualsTestResultIs(result As Boolean, actual As Variant, expected As Variant, message As String, desc As String)
assert.equals mResult, result, "result is " + Str(result)
assert.equals mActual, actual, "Actual is" + CStr(actual)
assert.equals mExpected, expected, "Expected is " + CStr(expected)
assert.equals mMessage, message, "Message is '" + message + "'"
assert.equals mDescription, desc, "Fail description"
End Sub


''
'Self shunt methods
Public Sub testResult(result As Boolean, actual As Variant, expected As Variant, tagMessage As String, fullDescription As String)
mResult = result
mActual = actual
mExpected = expected
mMessage = tagMessage
mDescription = fullDescription
End Sub

'OPTIONAL METHODS
Public Sub setup()
mResult = False
mActual = Null
mExpected = Null
mMessage = ""
mDescription = ""
End Sub

Public Function NumOfAsserts() As Long
NumOfAsserts = 40
End Function

